package chapter01;

public class Test23_Array {
    public static void main(String[] args) {
        //定义一个数组
        //定义一个整形数组
        int[] a;
        a = new int[]{1,2,3,4,5,6};
        //输出数组胡长度
        System.out.println(a.length);
        double[] b = new double[5];
        boolean[] c = new boolean[3];
        //数组的取值
        System.out.println(a[0]);
        System.out.println(a[5]);
        //超界
        //System.out.println(a[6]);
        //如果对没有赋值的数组取下标
        System.out.println(b[0]);
        System.out.println(c[0]);
        //数组值改变
        a[0] = 100;
        System.out.println(a[0]);
        //遍历数组元素
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }
        for(int i:a){
            System.out.println(i);
        }
    }
}
